﻿<!--#include file="const.inc"-->
<%
'====================================================================
' 感谢使用晴天3G智能建站系统..
' 作者:梁永强.QQ:766750857
' 官方网址:wap.qt3g.com
' 声明:软件版权归作者所有,没有经过作者本人同意不得非法破解和传播本程序
'====================================================================
%>

<%	dim rs,sql,i,id,PageCount,Page,PageOut,PageIn,PageSize,content,classid,RepCount,gm,viphy,nid,read,readtime,viphyy,vipp,zff,flegid,nameca,namecb
	PageSize=qingtian.weid
        if PageSize<10 then PageSize=500
	id=Request.QueryString("id")
	if id="" then id=1
	if not isnumeric(id) then id=1
	id=clng(id)

    	Page = Request("page")      '当前页数
    	If Page = "" Then Page = 1
   	If Not IsNumeric(Page) Then Page = 1
    	Page = CLng(Page)
    	If Page < 1 Then Page = 1


	if sid<>"Null" then

	Set Rs = Server.CreateObject("Adodb.Recordset")

	Sql = "select vip,id from qingtian_user where sid='"&md5(sid) & md5(strReverse(sid))&"'"
	Rs.Open Sql,conn,1,1

	if not (rs.bof and rs.eof)  then
		viphy=rs("vip")
		nid=rs("id")
	end if
	Rs.close	

	Sql = "select id from qingtian_paym where ext=2 and listid="&id&" and  nid="&qingtian.nid&""
	Rs.Open Sql,conn,1,1
	if not (rs.bof and rs.eof)  then
		gm=1
	else
		gm=0
	end if
	Rs.close	

	set rs=nothing
	else
		viphy=0
		gm=0
	end if



	conn.execute("update qingtian_viewli set ReadCount=ReadCount+1 where id="&id&"")

	Set Rs = Server.CreateObject("Adodb.Recordset")

	Sql = "select name,classid,flegid,Urls,zuozhe,laiyuan,RepCount,ReadCount,[WriteTime],[readtime],tuijian,vip,zf,viphy from qingtian_viewli where id="&id
	Rs.Open Sql,conn,1,1
	if not (rs.bof and rs.eof)  then
                zff=rs("zf")
		viphyy=rs("viphy")
		vipp=rs("vip")
                urls1=RS("urls")
		readtime=rs("readtime")
                name=rs("name")
                zuozhe=rs("zuozhe")
                laiyuan=rs("laiyuan")
                ReadCount1=rs("ReadCount")
                WriteTime=rs("WriteTime")
		Dim path,FsoObj,tempfileOBJ,txt
		Path = server.mappath(Request.ServerVariables("SCRIPT_NAME"))
		Path=left(Path,instrrev(Path,"\" ) - 1 )
		path=Path & "/" & RS("urls")

    		Set FsoObj=Server.CreateObject("Scripting.FileSystemObject")
                on error resume next
		IF FSOObj.FileExists(path) = True then
   		Set tempfileOBJ = FsoObj.OpenTextFile(path, 1, 0, 0 )
			txt=txt & tempfileOBJ.ReadAll 
		Set tempfileOBJ=Nothing
		end if
		Set FsoObj=Nothing
		if len(txt)>2 then txt=trim(left(txt,len(txt)-2))
		if rs("viphy")=1 then
			if viphy=1 then
			read=true
			else
			read=false
			end if
		elseif rs("vip")=1 and gm=0 then
				if rs("zf")=0 and sid<>"Null" then
					read=true
				else
					read=false
				end if
		else
			read=true

		end if

		RepCount=rs("RepCount")
		classid=rs("classid")
		flegid=rs("flegid")
                if flegid=0 then
                nameca="首页"
                else
                nameca=conn.execute("select name from [qingtian_class] where id="&flegid&"")("name")
                end if
                namecb=conn.execute("select name from [qingtian_class] where id="&classid&"")("name")
		contentt=txt
		if Request.QueryString("act")<>1 then
		

		''''''''''''''''''智能分页''''''''''''''''''''''
      		Dim  n
        	I = 1
        	Do
            	n = n + 1
            	If n = page Then
           	     PageIn = I
           	End If
            	If InStr(I, contentt, "[page]") - I < PageSize + PageSize / 4 * 3 And InStr(I, contentt, "[page]") <> 0 Then
            	    I = InStr(I, contentt, "[page]") + 6
            	Else
            	    I = I + PageSize
            	End If
            	If n = page Then
            	    PageOut = I
            	End If

        	Loop While I < Len(contentt)
       		PageCount = n
		if page>PageCount then page=PageCount

		if Pagein="" then Pagein=(PageCount-1)*PageSize+1
		if Pageout="" then Pageout=Len(contentt)-(PageCount-1)*PageSize+Pagein

		if len(contentt)>0 then contentt=replace(mid(contentt,Pagein,Pageout-Pagein),"[page]","")
		else
			PageCount=1
			Page=1
		end if
	Rs.close
select case v
case "0"
we0="<br/>"
hr="------------<br/>"
book="<input name=""remark"" type=""text"" maxlength=""128"" emptyok=""true"" size=""15"" value="""" /><br/><anchor title=""发表评论"">发表评论<go href='showing.asp?id="&id&"&amp;sid="&sidd&"' method='post'><postfield name=""remark"" value=""$(remark)"" /></go></anchor><br/>"
%>
<card title="<%=qingtian.utf8(name)%>"><p align="<%=qingtian.px%>">
<%
case "1"
hr=""
zi="<span style=""color:#FF5500"">"
zi0="</span>"
we="<div class=""footer"">"
sou="<div class=""block4"">"
dao="<div class=""navi"">"
we0="</div>"
ziz="<div style=""background-color:#FF5226;color:#E1E100"">"
book="<form action=""showing.asp?id="&id&"&amp;sid="&sidd&""" method=""post""><input type=""text"" name=""remark"" size=""15"" value="""" /><br/><input type=""submit"" value=""发表评论"" /></form><br/>"
%>
<title><%=qingtian.utf8(name)%></title>
</head>
<body>
<!--#include virtual="/css.inc"-->
<%
End Select		


		%><%


		if sid="Null" then
		%><%=we%><%=zi%>欢迎你<%=zi0%><a href="login.asp?sid=<%=sidd%>&amp;url=articview.asp?id=<%=id%>">注册/登陆</a><%=we0%><%
		else
		qingtian.info
                qingtian.addong("阅读了文章[url=/articview.asp?id="&id&"&sid=[sid]]"&name&"[/url]")
		end if
          %><%=qingtian.qingsav("1")%>
<%=sou%><a href="newli.asp?act=2&amp;listid=<%=classid%>&amp;sid=<%=sidd%>">最新</a>.<a href="downli.asp?act=2&amp;listid=<%=classid%>&amp;sid=<%=sidd%>">最热</a>.<a href="tuijianli.asp?act=2&amp;listid=<%=classid%>&amp;sid=<%=sidd%>">推荐</a>.<a href="zweid.asp?urls=/articview.asp?id=<%=id%>&amp;sid=<%=sidd%>">设置</a><%=we0%>
<%=we%>
<a href='viewli.asp?listid=<%=flegid%>&amp;sid=<%=sidd%>'><%=qingtian.utf8(nameca)%></a>&gt;<a href='viewli.asp?listid=<%=classid%>&amp;sid=<%=sidd%>'><%=qingtian.utf8(namecb)%></a>
<%=we0%>
		<%=dao%><b><%=qingtian.utf8(name)%>(阅<%=qingtian.utf8(ReadCount1)%>)</b><%=we0%><%=we%>[来源]:<%=qingtian.utf8(replace(laiyuan,"：",""))%><%=we0%>
	       <%=sou%>[时间]:<%=qingtian.FormatTime(WriteTime,0)%><%=we0%><%=hr%>
		<%if read=true  then
                Response.Write we
                if Request.QueryString("act")<>1 and  PageCount >1 then Response.Write("<a href='articview.asp?act=1&amp;id="&id&"&amp;page=" & Page& "&amp;sid="&sidd&"'>全文</a>[共"&PageCount&"页]<br/>")
		%>
		<%=qingtian.ubb(contentt)%><%=we0%>
		<%

	    	'分页
    		
		if  Request.QueryString("act")<>1 and  PageCount >1  Then 
    		    Response.Write("" & sou & "<a href='downtxt.asp?id="&id&"&amp;sid="&sidd&"&amp;url=" & urls1 & "'>下载TXT</a>")
		else
   		    Response.Write("" & sou & "<a href='downtxt.asp?id="&id&"&amp;sid="&sidd&"&amp;url=" & urls1 & "'>下载TXT</a>|<a href='bbs/souzan.asp?sid="&sidd&"&amp;name="&server.URLEncode(name)&"&amp;urls=/articview.asp?id="&id&"'>收藏</a>|<a href='articview.asp?id="&id&"&amp;page=" & Page  & "&amp;sid="&sidd&"'>分页</a>" & we0 & "")
    		End If
    	
    		'分页
    		If Page < PageCount Then
    		    Response.Write("<a href='articview.asp?id="&id&"&amp;page=" & Page + 1 & "&amp;sid="&sidd&"'>下页</a>")
    		End If     
    		If Page > 1 Then
    		    Response.Write("<a href='articview.asp?id="&id&"&amp;page=" & Page - 1 & "&amp;sid="&sidd&"'>上页</a>("&Page&"/"&PageCount&")" & we0 & "")
    		Elseif PageCount >1 then
    		    Response.Write("("&Page&"/"&PageCount&")" & we0 & "")
    		End If
            
    		Randomize()
    
    		If PageCount > 2 Then
                if v=0 then
     		    Response.Write("共"&len(txt)&"字<input name='Page' format='*N' size='2' maxlength='5'/><anchor>GO&gt;&gt;<go href='articview.asp?id="&id&"&amp;page=$(Page:n)&amp;sid="&sidd&"' method='post'><postfield name=""Page"" value=""$(Page:n)"" /></go></anchor><br/>")
                else
     		    Response.Write("<form action=""articview.asp?id="&id&"&amp;sid="&sidd&""" method=""post"">共"&len(txt)&"字<input type=""text"" name=""Page"" value="""" format=""*N"" size=""2"" maxlength=""5""/><input type=""submit"" value=""GO&gt;&gt;"" /></form><br/>")
                end if
   		End If
		else
			if viphyy=1 then
				if viphy=0  then
				%><%=we%>查看文章出错!该文章为VIP会员查看.请先成为本站VIP会员,再查看!<%=we0%><%=sou%>=<a href="user/shangchen.asp?act=2&amp;sid=<%=sidd%>">购买vip会员卡</a>=<%=we0%><%=hr%><%
				end if
			elseif vipp=1 and gm=0 then
				if zff=0 and sid="Null" then
				%><%=we%>查看文章出错!该文章为会员查看.请先登陆再查看!<%=we0%><%=hr%>
                                <%
				else
				%><%=we%>查看该文章需要<%=zff%><%=qingtian.bi%>,<a href="paym.asp?ext=2&amp;id=<%=id%>&amp;sid=<%=sidd%>">马上购买</a><%=we0%><%=hr%><%
				end if
			end if
		end if
		 %>
			<%=hr%><%=sou%>评论该文章:<%=we0%>	
		<%=book%>
		<%
	



            If DateDiff("m", readtime, Now()) > 0 Then
                conn.execute("update qingtian_viewli set [Monthread]=1,[readtime]='" & Now() & "' where [id]=" & id & "")
            Else
                conn.execute("update qingtian_viewli set [Monthread]=[Monthread]+1,[readtime]='" & Now() & "' where [id]=" & id & "")
            End If

            If DateDiff("ww", readtime, Now()) > 0 Then
                conn.execute("update qingtian_viewli set [Weekread]=1 where [id]=" & id & "")
            Else
                conn.execute("update qingtian_viewli set [Weekread]=[Weekread]+1 where [id]=" & id & "")
            End If

            If DateDiff("d", readtime, Now()) > 0 Then
                conn.execute("update qingtian_viewli set [Dayread]=1 where [id]=" & id & "")
            Else
                conn.execute("update qingtian_viewli set [Dayread]=[Dayread]+1 where [id]=" & id & "")
            End If




		Sql = "select top 3 id,content,user,uid from qingtian_view_reply where  listid="&id&"  order by id desc"

		Rs.Open Sql,conn,1,1
		if not (rs.bof and rs.eof)  then
		For i=1 to rs.RecordCount
dat=RepCount+1-i
dat1=dat mod 2
if dat1=0 then
%>


		<%=we%><%=zi%><%=dat%>楼.<%=zi0%>[<%=qingtian.utf8(rs("user"))%>]说:<%=qingtian.ubb(rs("content"))%><%=we0%>
<%
else
%>
<%=sou%><%=zi%><%=dat%>楼.<%=zi0%>[<%=qingtian.utf8(rs("user"))%>]说:<%=qingtian.ubb(rs("content"))%><%=we0%>




<%
                End If
		Rs.MoveNext
		next
		end if
	
		%>
			<%=we%><a href="showinglist.asp?infoid=<%=id%>&amp;sid=<%=sidd%>">查看网友评论(<%=RepCount%>条)</a><%=we0%>
		<%
	else
        qingtian.err("该文章不存在或已经被管理员删除!")
 	end if
	Rs.close
	


	Sql = "select top 1 id,name from qingtian_viewli where  classid="&classid&" and id<"&id&"  order by id desc"

	Rs.Open Sql,conn,1,1
	if not (rs.bof and rs.eof)  then
			%><%=sou%>下一条<a href="articview.asp?id=<%=rs(0)%>&amp;sid=<%=sidd%>"><%=qingtian.utf8(rs(1))%></a><%=we0%><%
	end if
	Rs.close	



	Sql = "select top 1 id,name from qingtian_viewli where  classid="&classid&" and id>"&id&"  order by id asc"

	Rs.Open Sql,conn,1,1
	if not (rs.bof and rs.eof)  then
			%><%=sou%>上一条<a href="articview.asp?id=<%=rs(0)%>&amp;sid=<%=sidd%>"><%=qingtian.utf8(rs(1))%></a><%=we0%>
<%
	end if
	Rs.close	

          %><%=qingtian.qingsav("2")%><%
		%><%=we%><a href="viewli.asp?listid=<%=classid%>&amp;sid=<%=sidd%>">返回<%=namecb%></a><%=we0%>
<%
	set rs=nothing
end Function
%>
